#ifndef __M_LEVEL_H__
#define __M_LEVEL_H__


/*
    1.定义枚举类，枚举出日志等级
    2.提供转换接口，将枚举转换为对应字符串
*/

#include <string>
#include <vector>
#include <array>

namespace MyLog
{
    class LogLevel
    {
    public:
        enum class Level
        {
            UNKNOWN = 0,
            DEBUG,
            INFO,
            WARN,
            ERROR,
            FATAL,
            OFF
        };

        static std::string ToString(Level val)
        {
            int index = static_cast<int>(val);
            if(index >= 1 && index < _level_map.size())
                return _level_map[index];
            return _level_map[0];
        }
    private:
        static const std::array<std::string, 7> _level_map;
    };
    const std::array<std::string, 7> MyLog::LogLevel::_level_map = {
        "UNKNOWN", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF"
    };
}


# endif